package com.cheng.web.action.takedelivery;

import java.util.HashMap;
import java.util.Map;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.cheng.bos.actionUtils.ActionUtils;
import com.cheng.domain.takedelivery.Order;
import com.cheng.service.takedelivery.OrderService;
import com.opensymphony.xwork2.ActionContext;

@Namespace("/order")
@ParentPackage("json-default")
@Controller
@Scope("prototype")
public class OrderAction extends ActionUtils<Order>{
	
	@Autowired
	private OrderService orderService;
	
	//根据订单号查找订单
	@Action(value="findbyordernum",results={@Result(name="success",type="json")})
	public String findOrderByOrderNum(){
		Order order =orderService.findOrderByOrderNum(model.getOrderNum());
		Map<String, Object> resault = new HashMap<>();
		if (order != null) {
			//存在订单
			resault.put("success", true);
			resault.put("order", order);
		}else{
			resault.put("success", false);
		}
		ActionContext.getContext().getValueStack().push(resault);
		return SUCCESS;
	}

}
